<?php
/**
 * Created by PhpStorm.
 * User: Edward
 * Date: 2019/6/3
 * Time: 15:37
 */

namespace app\admin\model;

use traits\model\SoftDelete;
class Shop extends Base {
    use SoftDelete;
    /**
     *
     * @param $data
     * @return Shop
     */
    public static function createShop($data){
        return self::create($data);
    }

    /**
     * 通过手机号查询商家
     * @param $phone
     * @return array|\PDOStatement|string|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function searchShopByPhone($phone){
        return self::where([
            'phone' => $phone
        ])->find();
    }
    public function pName(){
        return $this->hasOne("ChinaProvince","id",'province')->bind(['province_name'=>'name']);
    }
    public function cName(){
        return $this->hasOne("ChinaCity","id",'city')->bind(['city_name'=>'name']);
    }
    public function aName(){
        return $this->hasOne("ChinaArea","id",'area')->bind(['area_name'=>'name']);
    }

}